package util
{
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	
	import util.err.FileNotExistErr;

	public class ConfigHelper
	{
		public function ConfigHelper()
		{
		}
		
		/**
		 * 阻塞式的读取本地xml文件 
		 * @param path
		 * 
		 */			
		public static function loadXmlLocal( path:String ):XML
		{
			var configFile:File = new File( path );
			
			if( !configFile.exists )
			{
				throw new FileNotExistErr( configFile );
			}
			
			var configFileStream:FileStream = new FileStream();
			
			configFileStream.open( configFile, FileMode.READ );
			
			var configXml:XML = new XML( configFileStream.readUTFBytes( configFileStream.bytesAvailable ) );
			
			configFileStream.close();
			
			return configXml;
		}
		
	}
}